//
//  RegisterViewController.m
//  诗韵
//
//  Created by Song on 2018/3/19.
//  Copyright © 2018年 Song. All rights reserved.
//

#import "RegisterViewController.h"
#import "SHIYUNTabBarController.h"

@interface RegisterViewController ()
- (IBAction)backBtn:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *name;
@property (weak, nonatomic) IBOutlet UITextField *idNum;
@property (weak, nonatomic) IBOutlet UITextField *pwd;
@property (weak, nonatomic) IBOutlet UITextField *rePwd;
@property (weak, nonatomic) IBOutlet UIButton *zhuce;
- (IBAction)zhuceClick:(id)sender;

@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.name];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.idNum];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.pwd];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.rePwd];
}

-(void)textChange {
    BOOL flag = NO;
    if (self.pwd.text == self.rePwd.text) {
        flag = YES;
    }
    
    self.zhuce.enabled = (self.name.text.length && self.idNum.text.length && self.rePwd.text.length && self.pwd.text.length && (flag == YES));
}


- (IBAction)backBtn:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)zhuceClick:(id)sender {
    SHIYUNTabBarController *tabbar = [[SHIYUNTabBarController alloc] init];
    [self presentViewController:tabbar animated:YES completion:nil];
}
@end
